package consumer.service;

import consumer.service.fallback.UserServiceFallbackFactory;
import entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import vo.ResponseResult;

@Service
//内部调用
//@FeignClient("springcloud-nacos-provider")
//@FeignClient(value = "springcloud-nacos-provider",fallback = UserServiceFallback.class)
//@FeignClient(value = "springcloud-nacos-provider",fallbackFactory = UserServiceFallbackFactory.class)
//外部调用
@FeignClient(value = "springcloud-nacos-gateway",fallbackFactory = UserServiceFallbackFactory.class)
public interface UserService {

//    @PostMapping("/user")
//    public ResponseResult add1(@RequestParam("username") String username,
//                              @RequestParam("password") String password);
//
//    @PostMapping("/user/add2")
//    public ResponseResult add2(@RequestBody User user);
//
//    @PostMapping("/user/add3")
//    public ResponseResult add3(@SpringQueryMap User user);
//
//    @DeleteMapping("/user/{id}")
//    public ResponseResult remove(@PathVariable("id") Integer id);
//
//    @PutMapping("/user")
//    public ResponseResult modify(@RequestParam("id") Integer id,
//                                 @RequestParam("username") String username,
//                                 @RequestParam("password") String password);
//
//    @GetMapping("/user/{id}")
//    public ResponseResult findById(@PathVariable("id") Integer id);
//
//    @GetMapping("/user")
//    public ResponseResult findAll();


    @PostMapping("/ums/user")
    public ResponseResult add1(@RequestParam("username") String username,
                               @RequestParam("password") String password);

    @PostMapping("/ums/user/add2")
    public ResponseResult add2(@RequestBody User user);

    @PostMapping("/ums/user/add3")
    public ResponseResult add3(@SpringQueryMap User user);

    @DeleteMapping("/ums/user/{id}")
    public ResponseResult remove(@PathVariable("id") Integer id);

    @PutMapping("/ums/user")
    public ResponseResult modify(@RequestParam("id") Integer id,
                                 @RequestParam("username") String username,
                                 @RequestParam("password") String password);

    @GetMapping("/ums/user/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id);

    @GetMapping("/ums/user")
    public ResponseResult findAll();

}
